<?php

namespace app\apijson\controller;

use support\BaseResponse;
use support\Request;
use app\apijson\core\ApiJsonFactory;

class ReqController
{
    /**
     * GET 请求
     * @param Request $request
     * @return \support\Response
     */
    public function gets(Request $request)
    {
        $json = $request->all();
        $result = ApiJsonFactory::query($json, 'get');
        return BaseResponse::ok(data: $result);
    }

    /**
     * POST 请求
     * @param Request $request
     * @return \support\Response
     */
    public function posts(Request $request)
    {
        $json = $request->all();
        $result = ApiJsonFactory::query($json, 'post');
        return BaseResponse::ok(data: $result);
    }

    /**
     * PATCH 请求
     * @param Request $request
     * @return \support\Response
     */
    public function patchs(Request $request)
    {
        $json = $request->all();
        $result = ApiJsonFactory::query($json, 'patch');
        return BaseResponse::ok(data: $result);
    }

    /**
     * DELETE 请求
     * @param Request $request
     * @return \support\Response
     */
    public function deletes(Request $request)
    {
        $json = $request->all();
        $result = ApiJsonFactory::query($json, 'delete');
        return BaseResponse::ok(data: $result);
    }
}
